<template>
	<view class="wrap">
		<u-waterfall v-model="flowList" ref="uWaterfall" add-time=0>
			<template v-slot:left="{leftList}">
				<view class="demo-warter warter-left" v-for="(item, index) in leftList" :key="index"
					@click="goPage(item)">
					<!-- 警告：微信小程序中需要hx2.8.11版本才支持在template中结合其他组件，比如下方的lazy-load组件 -->
					<u-lazy-load threshold="-450" :image="item.image" :loading-img="loadingImg" :index="index">
					</u-lazy-load>
					<!-- <image :image="item.image"></image> -->
					<image v-if="(item.imageList.length >= 2 )" class="iconss" src="../../static/iconss.png"></image>


					<!-- </view> -->
					<!-- <u-icon name="close-circle-fill" color="#fa3534" size="34" class="u-close" @click="remove(item.id)"></u-icon> -->
				</view>
			</template>
			<template v-slot:right="{rightList}">
				<view class="demo-warter warter-right" v-for="(item, index) in rightList" :key="index"
					@click="goPage(item)">
					<u-lazy-load threshold="-450" :image="item.image" :loading-img="loadingImg" :index="index">
					</u-lazy-load>
					<image v-if="(item.imageList.length >= 2 )" class="iconss" src="../../static/iconss.png"></image>
					<!-- <u-icon name="close-circle-fill" color="#fa3534" size="34" class="u-close" @click="remove(item.id)"></u-icon> -->


				</view>
			</template>
		</u-waterfall>
		<loading :toast="loadStatus" :title="'暂无动态'"></loading>
		<!-- <u-loadmore v-if="loadStatus != 'loadmore'" :load-text="loadText" :status="loadStatus" @loadmore="addRandomDatas"></u-loadmore> -->
	</view>
</template>

<script>
	import loading from "@/components/loading/loading.vue"
	export default {
		data() {
			return {
				loadText: {
					loadmore: '已经到底了',
					loading: '努力加载中',
					nomore: '已经到底了'
				},
				loadingImg: "https://z3.ax1x.com/2021/09/25/4s9cSx.png"
			}
		},
		props: {
			flowList: {
				type: Array
			},
			loadStatus: {
				type: String,
				default: 'loadmore'
			},
			list: {
				type: Array
			},
			swiperCurrent: {
				type: Number
			}
		},
		components:{
			loading
		},
		mounted() {

console.log('flowList----------------->',this.flowList)
		},
		watch: {
			flowList(newVal, oldVal) {
                
				// debugger

			},
			swiperCurrent(newVal, oldVal) {
				// debugger
				if (newVal != oldVal) {
					console.log('到组件的数据===》', newVal)

					// this.$refs.uWaterfall.clear();
				}


			},

		},
		methods: {
			addRandomData() {
				this.$emit("addRandomDatas")
			},
			goPage(data) {
				console.log(data)

				// debugger
				// debugger
				// /amianfrontend/dynamic/{dynamicId}
				// debugger
				// let 
				// if(){

				// }
				this.initOnShow().then(res => {
					this.$emit('updataShow', res)
					// debugger
					if (res == 2) {
						if (data.page == '/pages/flour/flourdetails/flourdetails') {
							let src = `${data.page}?dynamicId=${data.dynamicId}`;
							// debugger
							uni.navigateTo({
								url: src
							})
						}

					}
				})


			},
			initOnShow() {
				// uni.getStorage({
				//     key: 'userPhone',
				//     success: res => {
				// 		this.show = false
				// 	},
				// 	fail: err => {
				// 		this.show = true
				// 	}
				// });
				return new Promise((ress, rejj) => {
					this.$apis.accountInfo().then(res => {
						if (res.code == 200) {
							this.userPhoneApi = res.data.phone;
							this.imgs = res.data.awardPrivilegeBg;
							if (res.data.needInviteCode) {

								if (res.data.inviteCode) {
									this.inviteCodex = res.data.inviteCode.code;
									if (!res.data.phone) {
										// debugger
										// this.isShow = 0
										// this.$emit('updataShow',)
										ress(0);
									} else {
										// debugger
										// this.isShow = 2
										// this.$emit('updataShow',2)
										ress(2);
									}
								}
							} else {
								if (!res.data.phone) {
									// debugger
									// this.$emit('updataShow',1)
									ress(1);
									// this.isShow = 1
									// 

								} else {
									// debugger
									// this.$emit('updataShow',2)
									ress(2);
									// this.isShow = 2
								}
							}
						}



						console.log("个人信息成功", res)
					}).catch(err => {
						// this.isShow = 0;

						ress(0);
						console.log("个人信息错误", err)
					})
				})




				// let labelCode
				// uni.getStorage({
				//     key: 'labelCode',
				//     success: res => {
				//         console.log(res.data);
				// 		if(res.data == 200){
				// 			uni.showToast({
				// 				title: "已保存，可在「我的-名片」修改",
				// 				icon: "none",
				// 				duration: '2500'
				// 			})
				// 			uni.removeStorage({
				// 			    key: 'labelCode'
				// 			});
				// 		}
				//     }
				// });
			},

			ff_day(end) {
				// debugger
				let stateTime = new Date().getTime();
				let endTime = new Date(end).getTime();
				let moveTime = endTime - stateTime;
				if (moveTime > 0) {
					return new Date(moveTime).getDate();
				} else {
					return 0
				}
			}
		}
	}
</script>

<style lang="scss">
	.warp {
		.demo-warter {
			margin-bottom: 5rpx;

		}

		.u-close {
			position: absolute;
			top: 32rpx;
			right: 32rpx;
		}

		.demo-image {
			width: 100%;
			// border-radius: 4rpx;
		}

		.demo-title {
			font-size: 30rpx;
			margin-top: 5rpx;
			color: $u-main-color;
		}

		.demo-tag {
			display: flex;
			// margin-top: 5px;
		}

		.demo-tag-owner {
			background-color: $u-type-error;
			color: #FFFFFF;
			display: flex;
			align-items: center;
			padding: 4rpx 14rpx;
			border-radius: 50rpx;
			font-size: 20rpx;
			line-height: 1;
		}
		
		.warter-left {
			margin-right: 5rpx !important;
		}
		
		.warter-right {
			margin-left: 5rpx !important;
		}
		.demo-warter {
			margin-bottom: 10rpx !important;
			position: relative;
		}



		.demo-price {
			font-size: 30rpx;
			color: $u-type-error;
			margin-top: 5px;
		}

		.demo-shop {
			font-size: 22rpx;
			color: $u-tips-color;
			margin-top: 5px;
		}


	}

	.iconss {
		width: 40rpx;
		height: 47rpx;
		position: absolute;
		top: 15rpx;
		right: 8rpx;
	}
</style>
